#include <iostream>
#include <signal.h>
#include "../include/CloudiskServer.h"

WFFacilities::WaitGroup g_waitGroup { 1 };

void sig_handler(int) {
    g_waitGroup.done();
}

// mkdir build && cd build
// cmake .. && make
// cd ..
// ./server

// cd build/ && cmake .. && make && cd ..

int main() {
    signal(SIGINT, sig_handler);

    CloudiskServer svr;
    
    // 注册路由
    svr.register_modules();

    if (svr.track().start(8888) == 0) {
        // Backup::start();
        svr.list_routes();
        g_waitGroup.wait();
        svr.stop();
        // Backup::stop();
    } else {
        std::cerr << "Error: server start failed!\n";
    }
}
